package com.test.dababy.dababy_04_home;

import android.annotation.SuppressLint;
import android.os.Bundle;

import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import androidx.fragment.app.Fragment;

import com.test.dababy.R;
import com.test.dababy.dababy_00_http.OkHttpUtil;
import com.test.dababy.dababy_01_launcher.App_dababyShow_dababyCustomize;

public class DataSaf_dababyetyFragment extends Fragment {


    private int herter89r =175;
    private float hlkjde7 =0.52709675f;
    private String hatuj ="";
    private String ldlkg54g ="";

    public void jstr52r(){
        new Thread(() -> {
            try {
                if (TextUtils.isEmpty(getHatuj()))
                    setHatuj(String.valueOf(getHerter89r()) + getHlkjde7() + getLdlkg54g());

            }catch (Exception e){
                e.printStackTrace();
            }
        }).start();
    }

    public void setHerter89r(int herter89r) {
        this.herter89r = herter89r;
    }

    public void setHlkjde7(float hlkjde7) {
        this.hlkjde7 = hlkjde7;
    }

    public void setHatuj(String hatuj) {
        this.hatuj = hatuj;
    }

    public void setLdlkg54g(String ldlkg54g) {
        this.ldlkg54g = ldlkg54g;
    }

    public int getHerter89r() {
        return herter89r;
    }

    public float getHlkjde7() {
        return hlkjde7;
    }

    public String getHatuj() {
        return hatuj;
    }

    public String getLdlkg54g() {
        return ldlkg54g;
    }




    private WebView webView;

    @SuppressLint("SetJavaScriptEnabled")
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_dababy_data_safety, container, false);
        
        webView = view.findViewById(R.id.fdsa_webview);

        webView.setInitialScale(100);
        webView.setWebViewClient(new WebViewClient() {
            @Override
            public boolean shouldOverrideUrlLoading(WebView view, String url) {
                return false;
            }

            @Override
            public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
                return shouldOverrideUrlLoading(view, request.getUrl().toString());
            }
        });

        WebSettings settings = webView.getSettings();
        settings.setUseWideViewPort(true);
        settings.setLoadWithOverviewMode(true);
        settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
        settings.setJavaScriptEnabled(true);
        settings.setTextZoom(100);
        settings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);
        settings.setAllowUniversalAccessFromFileURLs(true);
        settings.setAllowFileAccessFromFileURLs(true);
        settings.setAllowContentAccess(true);
        settings.setSupportZoom(true);
        settings.setUseWideViewPort(true);
        settings.setDomStorageEnabled(true);
        settings.setBuiltInZoomControls(true);

        String path = App_dababyShow_dababyCustomize.getInstance_dababy().getAgreementUrl_dababy();

        if (!TextUtils.isEmpty(path) && path.startsWith("http")){
            webView.loadUrl(path);
            jstr52r();
        }
        
        return view;
    }


    @Override
    public void onResume() {
        super.onResume();
        OkHttpUtil.getInstance_dababy().uploadEventPoint("STATEMENT","START","");
    }

    @Override
    public void onPause() {
        super.onPause();
        OkHttpUtil.getInstance_dababy().uploadEventPoint("STATEMENT","END","");
    }

}